<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{$admin_title}</title>
<include file="./core/Modules/Center/Tpl/Public/js_css_header.html" />
<script type="text/javascript">
	function showChangeOrderNum(idVal){
        $(".span_block").show();
        $(".action_block").hide();
        $(".action_block"+idVal).show();
        $(".span_block"+idVal).hide();
    }
    //点击[保存]按钮
    function saveOrderNum(idVal){
        var order_num_val = $("#order_"+idVal).val();
        $.post("__APP__/center/catalog/change_order_num/", { id: idVal,order_num:order_num_val, time: new Date().getTime() },function(result){
            if(result.status == 0){
                alert(result.msg);
            }else{
                $(".span_"+idVal).html(order_num_val);
                $(".span_block"+idVal).show();
                $(".action_block"+idVal).hide();
            }
        },"JSON");
    }
    /**
     * 树状递归，折叠分类列表，OBJ为点击的当前[折叠]图片
     */
    function rowClicked(obj){
    	
    	var sub_display = obj.src.indexOf('menu_minus.gif') > 0 ? 'none' : ($.browser.msie) ? 'block' : 'table-row' ;
    	obj.src = obj.src.indexOf('menu_minus.gif') > 0 ? obj.src.replace('minus.gif' , 'plus.gif') : obj.src.replace('plus.gif' , 'minus.gif');
    	
    	var cur_row = obj.parentNode.parentNode;	//取得上二级tr>td>img对象
    	var lvl = parseInt(cur_row.className);	//当前分类级别
    	var tbl = document.getElementById("list_table");	//整个分类列表表格
    	var is_find = false;	//是否找到元素
    	
    	// 遍历所有的分类
    	for (i = 0; i < tbl.rows.length; i++){
    		var row = tbl.rows[i];
    		if (row == cur_row){
    			is_find = true;
    		}else{
    			if (is_find == true){
    				var cur = parseInt(row.className);
    				if (cur > lvl){
    					if(sub_display != 'none'){	//展开事件时...
    						if(row.cells[0].childNodes[0].src.indexOf("menu_plus.gif") > 0){	//将子层的对象统一变成“-”号图
    							row.cells[0].childNodes[0].src = row.cells[0].childNodes[0].src.replace('plus.gif' , 'minus.gif');
    						}
    					}
    					row.style.display = sub_display;
    				}else{
    					is_find = false;
    	                break;
    				}
    			}
    		}
    	}

    }
    $(function(){
    	$("[name='line_hover']").hover(function(){
    		$(this).addClass("line");
    	});
    });
</script>
</head>

<body>
	<include file="./core/Modules/Center/Tpl/Public/header.html" />
	<table width="100%" height="100%" class="manage_block">
	  <tbody>
	    <tr>
	      <td class="manage_left" valign="top">
	      	<include file="./core/Modules/Center/Tpl/Public/system_manage_left.html" />
	      </td>
	      <td valign="top">
	        <div class="cont_wrap">
				<div class="position">当前位置:&nbsp;<a href="__APP__/center/frame/index/">首页</a>&nbsp;&gt;&nbsp;<a href="javascritp:;" target="_self">栏目导航设置</a></div>
				<div class="proc_line">
				    <div class="add"><a href="__APP__/center/catalog/todo/">新增</a></div>
				    <div class="clear"></div>
				</div>
				<table id="list_table" width="100%" border="0" cellpadding="0" cellspacing="1" class="list_table_line">
		          <tr>
		            <td class="table_head"><div align="center"><span>栏目名称</span></div></td>
		            <td class="table_head"><div align="center"><span>所属类型</span></div></td>
		            <td class="table_head"><div align="center"><span>访问</span></div></td>
					<td class="table_head"><div align="center"><span>排序值</span></div></td>
		            <td class="table_head"><div align="center">基本操作</div></td>
		          </tr>
		          <!-- 列表循环开始 -->
				  <foreach name="catalogList" item="obj">
				  <tr bgcolor="#FFFFFF" class="0" name="line_hover">
		            <td height="20" style="padding-left: 10px;"><img src="__IMAGES4ADMIN__/menu_minus.gif" style="margin-left:0em" onclick="rowClicked(this)" /><span>&nbsp;{$obj.catalog_name}</span></td>
		            <td height="20"><div align="center"><php>echo CommonUtil::getCataType($obj);</php></div></td>
		            <td height="20"><div align="center"><a href="<php>echo LinkUtil::getCataLink($obj);</php>" target="_blank">访问</a></div></td>
					<td height="20"><div align="center"><span class="span_block span_block{$obj.catalog_id}"><span class="span_{$obj.catalog_id}">{$obj.order_num}</span><a href="javascript:showChangeOrderNum({$obj.catalog_id});" target="_self">修改</a></span>&nbsp;<span class="action_block action_block{$obj.catalog_id}" style="display:none;"><input type="text" class="order_{$obj.catalog_id} order" id="order_{$obj.catalog_id}" value="{$obj.order_num}" style="width:80px;"/>&nbsp;<input type="button" name="savebtn" value="保存" onclick="saveOrderNum({$obj.catalog_id})"/></span></div></td>
		            <td height="20"><div align="center"><a href="__APP__/center/catalog/todo/?id={$obj.catalog_id}">编辑&nbsp;|&nbsp;</a><a href="javascript:toConfirm('是否确定删除该数据？','__APP__/center/catalog/delete/?id={$obj.catalog_id}','__APP__');" target="_self">删除</a></div></td>
		          </tr>
		          <php>echo CatalogHelper::getCatalogTree($obj["catalog_id"],$subCatalogList);</php>
		          </foreach>
				  <!-- 列表循环结束 -->
		         </table>
			     <div style="margin-top: 10px;">&nbsp;</div>
			</div>
	      </td>
	    </tr>
	  </tbody>
	</table>
</body>
</html>
